package alarm;

import org.snmp4j.smi.Integer32;

public enum AlarmStatus {
	valid("Valido"), 
	createRequest("Crea richiesta"),
	underCreation("In creazione"),
	invalid("Non valido");
	
	private String description = null;
	
	private AlarmStatus(String description) {
		this.description = description;
	}
	
	public int getValue() {
		switch (this) {
		case valid: return 1;
		case createRequest: return 2;
		case underCreation: return 3;
		case invalid: return 4;
		default: return 1;
		}
	}
	
	@Override
	public String toString() {
		return description;
	}

	public static AlarmStatus fromString(final String value) {
		if (value.equals(valid.toString()))
			return valid;
		else if (value.equals(createRequest.toString()))
			return createRequest;
		else if (value.equals(underCreation.toString()))
			return underCreation;
		else if (value.equals(invalid.toString()))
			return invalid;
		else
			return valid;
	}
	
	public Integer32 toVariable() {
		return new Integer32(getValue());
	}

	public static AlarmStatus fromVariable(Integer32 variable) {
		switch (variable.getValue()) {
		case 1: default: return valid;
		case 2: return createRequest;
		case 3: return underCreation;
		case 4: return invalid;
		}
	}
	
}